<template>
	<div id="toTop" @click="goTop" v-show="Top">
		<!--<Icon type="arrow-up-c" size="30" color="#fff"></Icon>-->
		<i class="iconfont icon-jiantou-copy-copy"></i>
	</div>
</template>

<script>
	export default {
	    data() {
	        return {
	            Top: false
	        }
	    },
	    mounted(){
	    	window.addEventListener("scroll",this.totopShow)
	    },
	    methods:{
	    	//监听出现
	    	totopShow(){
	    		var sTop = document.body||document.documentElement;
	    		sTop.scrollTop>500?this.Top=true:this.Top=false;
	    	
	    	},
	        goTop() {
	        	var sTop = document.body||document.documentElement;
	        	var timer=null;
	        	timer=setInterval(function(){
	        		sTop.scrollTop-=100
	        		if(sTop.scrollTop<=0){
	        			clearInterval(timer)
	        		}
	        	},25)
	        }
	    },
	}
</script>

<style lang="scss" scoped>
@import "~@/assets/scss/iconfont";
	#toTop {
    position: fixed;
    right: 10px;
    bottom: 20px;
    z-index: 1000;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background: #d43d3d;
    text-align: center;
    i{
      /* margin-top: 1px;*/
       font-size:36px;
       color: #fff;
    }
}
</style>